package com.heima.homeservicemanagementsystem.entity;

import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.heima.homeservicemanagementsystem.entity.common.ImageEntity;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;
import java.util.List;

/**
 * 服务详情;
 *
 * @author : http://www.chiner.pro
 * @date : 2025-4-12
 */
@Data
@Tag(name = "服务详情")
@Document(indexName = "servicedetails")
@TableName(value = "serviceDetails", autoResultMap = true)
@EqualsAndHashCode(callSuper = false)
public class Servicedetails {

    @TableId(type = IdType.ASSIGN_ID)
    @Schema(description = "主键")
    @Id
    private String id;

    @Schema(title = "服务名称", description = "")
    @Field(type = FieldType.Text, analyzer = "ik_max_word")

//    @JsonProperty("serviceName")
    @JsonAlias({"service_name"})
    private String serviceName;

    @Schema(title = "规格", description = "")
    @TableField(typeHandler = JacksonTypeHandler.class)
    @Field(type = FieldType.Keyword)  // 规格可能不需要全文索引，使用 Keyword 类型
    private List<String> specification;

    @Schema(title = "服务轮播图", description = "")
    @TableField(typeHandler = JacksonTypeHandler.class)
    @Field(type = FieldType.Object)  // 图像实体对象通常使用 Object 类型

    private List<ImageEntity> serviceCarousel;

    @Schema(title = "服务详情图片", description = "")
    @TableField(typeHandler = JacksonTypeHandler.class)
    @Field(type = FieldType.Object)  // 图像实体对象通常使用 Object 类型
    private List<ImageEntity> serviceDetails;

    @Schema(title = "已售数量", description = "")
    @Field(type = FieldType.Keyword)  // 售数量可以作为不分词的字符串，使用 Keyword 类型
    @JsonAlias({"quantitySold"})
    private String quantitysold;

    @Schema(title = "服务价格", description = "")
    @TableField(typeHandler = JacksonTypeHandler.class)
    @Field(type = FieldType.Keyword)  // 服务价格可以作为不分词的字符串，使用 Keyword 类型
    private List<String> price;

    @Schema(title = "服务简介", description = "")
    @Field(type = FieldType.Text, analyzer = "ik_max_word")  // 服务简介适合进行全文搜索
    private String remark;

    @Schema(title = "收藏的数量", description = "")
    @TableField(exist = false)
    @Field(type = FieldType.Integer)  // 收藏数量可以是整型字段
    private Integer scNumber;

    @Schema(title = "关联", description = "")
    @TableField(exist = false)
    @Field(type = FieldType.Keyword)  // 关联字段通常用作非分词类型，使用 Keyword 类型
    private String glId;
}
